package com.bjpowernode.javaweb.servlet;

import jakarta.servlet.annotation.WebServlet;

public class ReflectAnnotation {
    public static void main(String[] args) throws ClassNotFoundException {
        //使用反射机制将类上注解进行解析
        Class<?> c = Class.forName("com.bjpowernode.javaweb.servlet.WelcomeServlet");

        //先判断这个类上是否有注解对象
        if(c.isAnnotationPresent(WebServlet.class)){
            WebServlet annotation = c.getAnnotation(WebServlet.class);

            //获取注解的value属性值
            String[] values=annotation.value();
            for(String value:values){
                System.out.println(value);
            }
        }

    }
}
